from common.database import runSql
from flask import Blueprint, request
from model.User import User, db as userDb
from model.Type import Type, db as typeDb
from utils.JsonUtil import to_json_all  # 转json
from utils.Result import Response  # 统一返回工具类
import datetime
from sqlalchemy import desc
import json

# 蓝图名
type_blueprint = Blueprint('type', __name__)
# 创建工具类实例
Result = Response()


@type_blueprint.route('/list', methods=['GET'])
def getList():
    # 所有数据查询
    typeList = Type.query.all()
    #  如何数据为空
    if not typeList:
        return Result.error()
    # json转换
    jsonData = to_json_all(typeList)
    return Result.success(jsonData)

